package com.mark.web.sys.entity.from;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
 * @Description: 用户更新信息的校验表单
 * @Author: Kingsley
 * @CreateDate: 2018/10/4 21:26
 * @Version: 2.0
 * @Copyright : 豆浆油条个人非正式工作室
 */
@Data
@ApiModel(value = "用户更新表单")
public class UserUpdateFrom {

    private static final String PHONE_REGEXP = "^(((13[0-9])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8})|(0\\d{2}-\\d{8})|(0\\d{3}-\\d{7})$";
    private static final String USERNAME_REGEXP = "^([A-Za-z0-9_])*$";

    @ApiModelProperty(value = "用户名",required = true)
    @NotBlank(message = "用户名必填")
    @Pattern(regexp = USERNAME_REGEXP,message = "用户名只能包含数字、字母、下划线")
    @Length(min = 3,max = 15,message = "用户名的长度在3到15个字符")
    private String username;

    @ApiModelProperty(value = "邮箱",required = true)
    @NotBlank(message = "邮箱必填")
    @Email(message = "电子邮箱的格式不正确")
    private String email;

    @ApiModelProperty(value = "手机号码")
    @NotBlank(message = "手机必填")
    @Pattern(regexp = PHONE_REGEXP,message = "手机号格式不正确（13位有效数字）")
    private String phone;

    @ApiModelProperty(value = "问题")
    @NotBlank(message = "问题必填")
    private String question;

    @ApiModelProperty(value = "答案")
    @NotBlank(message = "回答问题必填")
    private String answer;

    @ApiModelProperty(value = "性别",hidden = true)
    @NotBlank(message = "性别不能为空")
    private String gender;
}
